<?php

namespace Modules\Admin\Entities;


use Illuminate\Foundation\Auth\User as AuthUser;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Hash;
use Spatie\Permission\Traits\HasRoles;

class User extends AuthUser
{
    use HasFactory,Notifiable,HasRoles;

    protected $table = 'sys_user';

    protected $guard_name = 'admin';

    protected $fillable = [
        'username','phone','nickname','email','password','api_token','remember_token'
    ];

    protected $hidden = ['password','api_token','remember_token'];


    /**
     * @param $value
     */
    public function setPasswordAttribute($value)
    {
        $this->attributes['password'] = Hash::make($value);
    }


    protected static function newFactory()
    {
        return \Modules\Admin\Database\factories\UserFactory::new();
    }
}
